<?php

function arvin(){
	print 'bbbbbbbbbbbbb';

}

class application{

protected static $instance = null;

protected $module = '';

protected $action = '';

private function __construction()
{
	// TODO
}

public static function getInstance()
{
	if(null == self::$instance){
		self::$instance = new self();
	}

	return self::$instance;
}

protected function route()
{
	//$uri = $_SERVER['REQUEST_URI'];

	if(isset($_GET['module'])){
		$this->module = $_GET['module'];
	}else{
		$this->module = ucfirst('index');
	}

	if(isset($_GET['action'])){
		$this->action = $_GET['action'];
	}else{
		$this->action = 'index';
	}

	return $this;
}

protected function dispatcher()
{
	if(false!== file_exists($this->module)){
		include_once($this->module.'.php');
		$module = $this->module;
		$action = $this->action;
		$object = new $module();

		if(method_exists($object,$action)){
			$object->$action.'()';
		}else{
			// TODO
		}
	}else{
		exit('请求的模块不存在!');
		// TODO
	}
}

public static function run()
{   
	application::getInstance()->route()->dispatcher();
}




}

?>